

** Er data
insheet using "$datadir/public_data/er.csv", clear names
reshape long v, i(Country code) j(time) str
rename v er
gen year=substr(time, 1, 4)
gen quarter=substr(time, 6, 1)
destring year, replace
destring quarter, replace
rename code s_ifscode 
rename Country country_macro
drop time
save "$datadir/constructed/macro.dta", replace


***** WEO Data for GDP
insheet using "$datadir/public_data/weo_gdp_usd_n.csv", clear
keep ifscode y* country
reshape long y, i(ifscode country) j(year)
rename ifscode s_ifscode
merge 1:m  s_ifscode year using "$datadir/constructed/macro.dta"
drop if _m==1
drop _m
replace s_ifscode=965 if s_ifscode==942
rename y ngdp_usd_a
replace ngdp_usd_a=ngdp_usd_a*1000
gen ngdp_usd_weo=ngdp_usd_a/4

save "$datadir/constructed/macro.dta", replace


*** merge ifs codes to get country names
use  "$datadir/constructed/macro.dta", clear
merge m:1 country_macro using "$datadir/public_data/ifs_country.dta"
replace country_macro=new if new!=""
drop new _m
save "$datadir/constructed/macro.dta", replace


